package day6;

import java.util.Scanner;

public class homework {

}

class Vehicle{
    int speed;
    int size;
    void move(int size){
        this.size=size;
    }
    void setSpeed(int speed){
        this.speed = speed;
    }
    void speedUp(int change){
        this.speed+=change;
        System.out.println(this.speed);
    }
    void speedDown(int change){
        this.speed-=change;
        System.out.println(this.speed);
    }
    public static void main(String[] args) {
        Vehicle vehicle = new Vehicle();
        vehicle.setSpeed(80);
        vehicle.move(60);
        System.out.println("速度:"+vehicle.speed);
        System.out.println("体积:"+vehicle.size);
        System.out.println("是否要改变速度Y/N");
        Scanner sc = new Scanner(System.in);
        char sf = sc.next().charAt(0);
        if(sf=='Y'){
            System.out.println("是否要加速Y/N");
            char sf2 = sc.next().charAt(0);
            if (sf2=='Y') {
                System.out.println("请输入改变后的速度:");
                vehicle.speedUp(sc.nextInt());
            }
            else if(sf2=='N') {
                System.out.println("请输入改变后的速度:");
                vehicle.speedDown(sc.nextInt());
            }
            else {
                System.out.println("结束程序");
            }
        }
        else {
            System.out.println("结束程序");
        }
    }
}


class Circle{
    int radius;
    double getArea(){
        return radius * radius * Math.PI;
    }
    double getPerimeter(){
        return 2 * radius * Math.PI;
    }
}

class test{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Circle circle = new Circle();
        System.out.println("请输入半径:");
        circle.radius=sc.nextInt();
        System.out.println("面积:"+circle.getArea());
        System.out.println("面积:"+circle.getPerimeter());
    }
}


class Draw {
    public void drawTrian() {
        for (int i = 1; i <= 5; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public void drawRec() {
        for (int i = 1; i <= 5; i++) {
            for (int j = 1; j <= 5; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public void drawPra() {
        for (int i = 1; i <= 5; i++) {
            for (int k = 1; k <= i - 1; k++) {
                System.out.print(" ");
            }
            for (int j = 1; j <= 5; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}

class TestDraw {
    public static void main(String[] args) {
        Draw draw = new Draw();
        draw.drawTrian();
        draw.drawRec();
        draw.drawPra();
    }
}


class Employee {
    private String name;
    private int age;
    private int sex;
    private double salary;

    public void FirstEmployee() {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入姓名:");
        name =sc.next();
        System.out.println("请输入年龄:");
        age = sc.nextInt();
        while (age<1||age>100){
            System.out.println("年龄输入错误，请重新输入:");
            age = sc.nextInt();
        }
        System.out.println("请输入工资:");
        salary = sc.nextDouble();
        while (salary<1||salary>20000){
            System.out.println("工资输入错误，请重新输入:");
            salary = sc.nextDouble();
        }
        System.out.println("请输入性别，男:0,女:1");
        sex = sc.nextInt();
        while (sex!=0&&sex!=1){
            System.out.println("性别输入错误，请重新输入:");
            salary = sc.nextDouble();
        }
        System.out.println("全部输入成功！！！");
    }

   public void print(Employee d){
       System.out.println("姓名:"+d.name);
       System.out.println("年龄:"+d.age);
       System.out.println("性别:"+d.sex);
       System.out.println("工资:"+d.salary);
   }

   public void addSal(){
        System.out.println("涨薪(元):");
        Scanner sc = new Scanner(System.in);
        double addsalary = sc.nextDouble();
       while (addsalary+salary<1||addsalary+salary>20000){
           System.out.println("涨幅输入错误，请重新输入:");
           addsalary = sc.nextInt();
       }
       salary+=addsalary;
       System.out.println("涨薪成功！！！");
   }
}

class testEloyee{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("初始化员工:");
        Employee employee = new Employee();
        employee.FirstEmployee();
        System.out.println("涨薪前:");
        employee.print(employee);
        System.out.println("是否需要涨薪Y/N");
        char sf = sc.next().charAt(0);
        if(sf=='Y'){
            employee.addSal();
            System.out.println("涨薪后:");
            employee.print(employee);
        }
        System.out.println("程序结束");
    }
}